<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>表格查询</title>
    <#assign base=request.contextPath  />
    <base id="base" href="${base}">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, adminUser-scalable=0">
    <link rel="stylesheet" href="${base}/static/win10/component/layui/css/layui.css" media="all">
    <script>
        var base = "${base}";
    </script>
</head>
<body>
<br>


<div class="demoTable" style="margin-left: 15px;">
    <form class="layui-form " action="">
        <div class="layui-form-item">
            <label>名字</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalName" id="personalName" autocomplete="off">
            </div>
            <label>求职状态 类型ID</label>
            <div class="layui-inline">
                <input class="layui-input" name="labelId" id="labelId" autocomplete="off">
            </div>
            <label>0男/1女</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalGender" id="personalGender" autocomplete="off">
            </div>
            <label>开始工作时间</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalStartTime" id="personalStartTime" autocomplete="off">
            </div>
            <label>生日</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalBirthday" id="personalBirthday" autocomplete="off">
            </div>
            <label>微信号</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalWecharNumber" id="personalWecharNumber" autocomplete="off">
            </div>
            <label>电话</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalPhone" id="personalPhone" autocomplete="off">
            </div>
            <label>邮箱</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalEmail" id="personalEmail" autocomplete="off">
            </div>
            <label>职位名称ID</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalPositionId" id="personalPositionId" autocomplete="off">
            </div>
            <label>修改时间</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalUpdateTime" id="personalUpdateTime" autocomplete="off">
            </div>
            <label>创建时间</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalCreateTime" id="personalCreateTime" autocomplete="off">
            </div>
            <label>用户头像</label>
            <div class="layui-inline">
                <input class="layui-input" name="personalPhoto" id="personalPhoto" autocomplete="off">
            </div>
            <button type="button" class="layui-btn" data-type="reload">
                <i class="layui-icon layui-icon-search">搜索</i>
            </button>
        </div>
    </form>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="toolbarDemo">


    <form class="layui-form " action="">
        <div class="layui-form-item" style="margin-left: 15px;">
            <div class="layui-btn-group">
                <#--<button type="button" class="layui-btn" lay-event="add">增加</button>-->
                <button type="button" class="layui-btn" lay-event="edit">编辑</button>
                <button type="button" class="layui-btn" lay-event="show">查看</button>
                <button type="button" class="layui-btn" lay-event="del">删除</button>
            </div>
        </div>

    </form>
</script>

<script src="${base}/static/win10/component/layui/layui.js?t=1"></script>
<script src="${base}/static/win10/js/jquery-1.8.3.min.js?t=1"></script>
<script>
    layui.use(['table'], function () {
        var table = layui.table;
        table.render({
            skin: 'line' //行边框风格
            , even: true //开启隔行背景
            , elem: '#test'
            , url: base + '/WeChatUser/wechatPersonal/admin/findWechatPersonalByPage'
            , toolbar: '#toolbarDemo'
            , cols: [[
                {type: 'radio'},
                {field: 'personalId', title: '个人信息ID'},
                {field: 'personalName', title: '名字'},
                {field: 'labelId', title: '求职状态 类型ID'},
                {
                    field: 'personalGender', title: '性别', templet: function (obj) {
                        console.log(obj)
                        var str = obj.personalGender;
                        return str == 0 ? '男' : '女'

                    }
                },
                {field: 'personalStartTime', title: '开始工作时间'},
                {field: 'personalBirthday', title: '生日'},
                {field: 'personalWecharNumber', title: '微信号'},
                {field: 'personalPhone', title: '电话'},
                {field: 'personalEmail', title: '邮箱'},
                {field: 'personalPositionId', title: '职位名称ID'},
                {field: 'updateTime', title: '修改时间'},
                {field: 'createTime', title: '创建时间'},
                {
                    field: 'personalPhoto', title: '用户头像', templet: function (obj) {

                        console.log('+++++' + obj.personalPhoto)
                        return '<img src=' + obj.personalPhoto + '></img>'

                    }
                }
            ]]
            , page: true
            , id: 'testReload'
        });
        //搜索
        var $ = layui.$, active = {
            reload: function () {
                //执行重载
                table.reload('testReload', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        personalName: $("#personalName").val(),
                        labelId: $("#labelId").val(),
                        personalGender: $("#personalGender").val(),
                        personalStartTime: $("#personalStartTime").val(),
                        personalBirthday: $("#personalBirthday").val(),
                        personalWecharNumber: $("#personalWecharNumber").val(),
                        personalPhone: $("#personalPhone").val(),
                        personalEmail: $("#personalEmail").val(),
                        personalPositionId: $("#personalPositionId").val(),
                        updateTime: $("#personalUpdateTime").val(),
                        createTime: $("#personalCreateTime").val(),
                        personalPhoto: $("#personalPhoto").val()
                    }
                }, 'data');
            }
        };
        $('.demoTable .layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });


        //头工具栏事件
        table.on('toolbar(test)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id); //获取选中行状态
            var data = checkStatus.data;  //获取选中行数据
            switch (obj.event) {
                case 'add':
                    //请继续补充以下逻辑
                    window.location.href = base + "/WeChatUser/wechatPersonal/admin/addWechatPersonalHtml"
                    break;
                case 'edit':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    //请继续补充以下逻辑
                    window.location.href = base + "/WeChatUser/wechatPersonal/admin/editWechatPersonalHtml?id=" + data[0].personalId
                    break;
                case 'show':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    //请继续补充以下逻辑
                    window.location.href = base + "/WeChatUser/wechatPersonal/admin/showWechatPersonalHtml?id=" + data[0].personalId
                    break;
                case 'del':
                    if (data.length === 0) {
                        layer.alert("请选择一条数据")
                        return;
                    }
                    layer.confirm('真的要删除吗?', function (index) {
                        $.ajax({
                            type: "POST",
                            url: base + '/WeChatUser/wechatPersonal/admin/delWechatPersonal',
                            data: {"id": data[0].personalId},
                            success: function (data) {
                                if (data.code === 200) {
                                    layer.msg(data.message)
                                    setTimeout(function () {
                                        window.location.reload();
                                    }, 500)
                                } else {
                                    layer.msg(data.message)
                                }
                            }
                        });
                    });
                    break;
            }
            ;
        });
    })
</script>
</body>
</html>